﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace HuiLian.Cloud.Controls
{
    public class CheckedRadioButton : RadioButton
    {
        public static readonly DependencyProperty ButtonWidthProperty = DependencyProperty.Register("ButtonWidth", typeof(double), 
            typeof(CheckedRadioButton), new PropertyMetadata(12.0));

        /// <summary>
        /// 图标宽度
        /// </summary>
        public double ButtonWidth
        {
            get { return (double)GetValue(ButtonWidthProperty); }
            set { SetValue(ButtonWidthProperty, value); }
        }

        public static readonly DependencyProperty ButtonHeightProperty = DependencyProperty.Register("ButtonHeight", typeof(double), 
            typeof(CheckedRadioButton), new PropertyMetadata(12.0));

        /// <summary>
        /// 图标高度
        /// </summary>
        public double ButtonHeight
        {
            get { return (double)GetValue(ButtonHeightProperty); }
            set { SetValue(ButtonHeightProperty, value); }
        }

        public static readonly DependencyProperty BorderColorProperty = DependencyProperty.Register("BorderColor", typeof(Brush),
            typeof(CheckedRadioButton), new PropertyMetadata(Brushes.Gray, OnPropertyChanged));

        /// <summary>
        /// 图片颜色
        /// </summary>
        public Brush BorderColor
        {
            set { SetValue(BorderColorProperty, value); }
            get { return (Brush)GetValue(BorderColorProperty); }
        }

        private static void OnPropertyChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs args)
        {
            CheckedRadioButton button = dependency as CheckedRadioButton;
            if (args.Property.Name.Equals("BorderColor"))
                button.BorderColor = (Brush)args.NewValue;
        }
    }
}
